//
//  CYContectUsViewController.m
//  cyjf
//
//  Created by tauCross on 2017/8/29.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYContectUsViewController.h"

#import "CYContectUsOnlineCell.h"
#import "CYContectUsPhoneCell.h"
#import "CYContectUsTitleCell.h"



@interface CYContectUsViewController ()

@property(nonatomic, strong)UIWebView *phoneGap;

@end


@implementation CYContectUsViewController

- (void)loadUI
{
    self.navigationItem.title = @"联系客服";
    
    self.phoneGap = [[UIWebView alloc] init];
    [self.contentView addSubview:self.phoneGap];
    
    NSMutableArray *cells = [NSMutableArray array];
    {
        CYContectUsTitleCellObject *cell = [CYContectUsTitleCellObject objectWithCellClass:[CYContectUsTitleCell class]];
        cell.title = @"在线客服";
        [cells addObject:cell];
    }
    {
        CYContectUsOnlineCellObject *cell = [CYContectUsOnlineCellObject objectWithCellClass:[CYContectUsOnlineCell class]];
        cell.title = @"QQ";
        cell.content = @"3308324340";
        [cells addObject:cell];
    }
    {
        CYContectUsOnlineCellObject *cell = [CYContectUsOnlineCellObject objectWithCellClass:[CYContectUsOnlineCell class]];
        cell.title = @"微信";
        cell.content = @"cheyijinfu";
        cell.isBottom = YES;
        [cells addObject:cell];
    }
    {
        CYContectUsTitleCellObject *cell = [CYContectUsTitleCellObject objectWithCellClass:[CYContectUsTitleCell class]];
        cell.title = @"客服热线";
        [cells addObject:cell];
    }
    {
        CYContectUsPhoneCellObject *cell = [CYContectUsPhoneCellObject objectWithCellClass:[CYContectUsPhoneCell class]];
        cell.title = @"400-880-0864";
        cell.subtitle = @"周一至周五 9:30-18:00 节假日除外";
        cell.phone = @"4008800864";
        [cells addObject:cell];
    }
    {
        CYContectUsPhoneCellObject *cell = [CYContectUsPhoneCellObject objectWithCellClass:[CYContectUsPhoneCell class]];
        cell.title = @"0571-81189304";
        cell.subtitle = @"周一至周五 18:00-21:00  节假日 9:30-18:00";
        cell.phone = @"057181189304";
        cell.isBottom = YES;
        [cells addObject:cell];
    }
    self.tableModel = [[NIMutableTableViewModel alloc] initWithSectionedArray:cells delegate:(id)[NICellFactory class]];
    self.tableView.dataSource = self.tableModel;
    [self.tableView reloadData];
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    id cellObject = [self.tableModel objectAtIndexPath:indexPath];
    if([cellObject isKindOfClass:[CYContectUsPhoneCellObject class]])
    {
        [self.phoneGap loadRequest:[NSURLRequest requestWithURL:[@"tel://" stringByAppendingString:[(CYContectUsPhoneCellObject *)cellObject phone]].tc_url]];
        return;
    }
}

@end
